package cn.study.executorService;

import java.util.concurrent.ArrayBlockingQueue;
/**
 * @Author     ：跟大佳一起学架构
 * @Description：线程怎么保证不消亡
 */
public class ThreadNoDieDemo {

    public static void main(String[] args) {
        ArrayBlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(10);
        new Thread(new Runnable() {
            @Override
            public void run() {
                Runnable task;
                while ((task = blockingQueue.poll()) != null) {
                    task.run();
                }
//                1、while
//                2、sleep
            }
        }).start();
    }
}
